package sol.leetcode;

/**
 * Reverse String
 */
public class Issue344 {
    public static String reverseString(String s) {
        if (s == null || s.length() == 0)
            return s;
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < s.length(); ++i) {
            sb.append(s.charAt(s.length() - 1 - i));
        }

        return sb.toString();
    }

    public static String reverseString2(String s) {

        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < s.length(); ++i) {
            sb.insert(0, s.charAt(i));
        }
        return sb.toString();
    }


    public static void main(String[] args) {
        String s = "Hello";
        System.out.println(reverseString(s));
    }
}
